package cn.com.eado.crm.m.db

import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import cn.com.eado.crm.app.MyApp
import cn.com.eado.crm.model.db.CompanyDao
import cn.com.eado.crm.model.db.CusUserDao
import cn.com.eado.crm.model.db.EnterpriseInfoDao
import cn.com.eado.crm.model.db.InstituteDao

@Database(entities = [
    Account::class,
    AppIcon::class,
    EnterpriseInfo::class,
    Province::class,
    Area::class,
    Client::class,
    HangYe::class,
    Track::class,
    Urgent::class,
    XingZhi::class,
    CusUser::class,
    Company::class,
    Institute::class
],
    version = 1)
abstract class MyDatabase : RoomDatabase(){

    companion object {
        @Volatile private var intence: MyDatabase? = null

        fun getInstance(): MyDatabase {
            if (intence == null){
                synchronized(MyDatabase::class.java){
                    if (intence == null){
                        intence = Room.databaseBuilder(MyApp.instance, MyDatabase::class.java, "pryado.db").build()
                    }
                }
            }
            return intence!!
        }
    }

    abstract fun accountDao(): AccountDao
    abstract fun appIconDao(): AppIconDao
    abstract fun enterpriseInfoDao(): EnterpriseInfoDao
    abstract fun provinceDao(): ProvinceDao
    abstract fun areaDao(): AreaDao
    abstract fun clientDao(): ClientDao
    abstract fun hangYeDao(): HangYeDao
    abstract fun trackDao(): TrackDao
    abstract fun urgentDao(): UrgentDao
    abstract fun xingZhiDao(): XingZhiDao
    abstract fun companyDao(): CompanyDao
    abstract fun instituteDao(): InstituteDao
    abstract fun cusUserDao(): CusUserDao
}